# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=kompose
pkgver=1.26.1
pkgrel=4
pkgdesc="Tool to move from docker-compose to Kubernetes"
url="https://kompose.io/"
license="Apache-2.0"
arch="all"
options="chmod-clean !check" # Require access to /tmp + bash, jq, ncurses
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/kubernetes/kompose/archive/v$pkgver.tar.gz"
builddir="$srcdir/src/github.com/kubernetes/$pkgname"

prepare() {
	mkdir -p "$srcdir/src/github.com/kubernetes/"
	ln -sf "$srcdir/$pkgname-$pkgver" "$srcdir/src/github.com/kubernetes/$pkgname"
	default_prepare
}

build() {
	GOPATH="$srcdir" make

	# Generate completion scripts
	./kompose completion bash > completion.bash
	./kompose completion zsh > completion.zsh
	./kompose completion fish > completion.fish
}

package() {
	install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname

	install -Dm644 completion.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 completion.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
	install -Dm644 completion.fish "$pkgdir"/usr/share/fish/completions/$pkgname.fish
}

sha512sums="
d9d181b12908298c11d99b9dda6f5e48b0bf44fca84836a7397bc726746f8d1a615a7b26aa90ea64a0fd90c50ddceae6c325d0c9d8c0c14840fc5828cefe8c23  kompose-1.26.1.tar.gz
"
